package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Modelinfo;
import com.ruoyi.system.service.IModelinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模型管理Controller
 * 
 * @author ruoyi
 * @date 2025-07-29
 */
@RestController
@RequestMapping("/system/modelinfo")
public class ModelinfoController extends BaseController
{
    @Autowired
    private IModelinfoService modelinfoService;

    /**
     * 查询模型管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:modelinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(Modelinfo modelinfo)
    {
        startPage();
        List<Modelinfo> list = modelinfoService.selectModelinfoList(modelinfo);
        return getDataTable(list);
    }

    /**
     * 导出模型管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:modelinfo:export')")
    @Log(title = "模型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Modelinfo modelinfo)
    {
        List<Modelinfo> list = modelinfoService.selectModelinfoList(modelinfo);
        ExcelUtil<Modelinfo> util = new ExcelUtil<Modelinfo>(Modelinfo.class);
        util.exportExcel(response, list, "模型管理数据");
    }

    /**
     * 获取模型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:modelinfo:query')")
    @GetMapping(value = "/{modelid}")
    public AjaxResult getInfo(@PathVariable("modelid") Long modelid)
    {
        return success(modelinfoService.selectModelinfoByModelid(modelid));
    }

    /**
     * 新增模型管理
     */
    @PreAuthorize("@ss.hasPermi('system:modelinfo:add')")
    @Log(title = "模型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Modelinfo modelinfo)
    {
        return toAjax(modelinfoService.insertModelinfo(modelinfo));
    }

    /**
     * 修改模型管理
     */
    @PreAuthorize("@ss.hasPermi('system:modelinfo:edit')")
    @Log(title = "模型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Modelinfo modelinfo)
    {
        return toAjax(modelinfoService.updateModelinfo(modelinfo));
    }

    /**
     * 删除模型管理
     */
    @PreAuthorize("@ss.hasPermi('system:modelinfo:remove')")
    @Log(title = "模型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{modelids}")
    public AjaxResult remove(@PathVariable Long[] modelids)
    {
        return toAjax(modelinfoService.deleteModelinfoByModelids(modelids));
    }
}
